--- a/libs/esl/Makefile.am
+++ b/libs/esl/Makefile.am
@@ -82,7 +82,7 @@ pymod: $(MYLIB)
 	$(MAKE) PYTHON=$(PYTHON) MYLIB="../$(MYLIB)" SOLINK="$(SOLINK)" CFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CFLAGS)" CXXFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CXXFLAGS)" CXX_CFLAGS="$(CXX_CFLAGS)" -C python
 
 py3mod: $(MYLIB)
-	$(MAKE) PYTHON3=$(PYTHON3) MYLIB="../$(MYLIB)" SOLINK="$(SOLINK)" CFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CFLAGS)" CXXFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CXXFLAGS)" CXX_CFLAGS="$(CXX_CFLAGS)" -C python3
+	$(MAKE) PYTHON3=$(PYTHON3) MYLIB="../$(MYLIB)" SOLINK="$(SOLINK)" CFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CFLAGS)" CXXFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CXXFLAGS)" CXX_CFLAGS="$(CXX_CFLAGS)" PYTHON3_CFLAGS="$(PYTHON3_CFLAGS)" PYTHON3_LDFLAGS="$(PYTHON3_LDFLAGS)" -C python3
 
 tclmod: $(MYLIB)
 	$(MAKE) MYLIB="../$(MYLIB)" SOLINK="$(SOLINK)" CFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CFLAGS)" CXXFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CXXFLAGS)" CXX_CFLAGS="$(CXX_CFLAGS)" -C tcl
@@ -106,7 +106,7 @@ pymod-install: pymod
 	$(MAKE) PYTHON=$(PYTHON) -C python install
 
 py3mod-install: py3mod
-	$(MAKE) PYTHON3=$(PYTHON3) -C python3 install
+	$(MAKE) PYTHON3=$(PYTHON3) PYTHON3_SITE_DIR="$(PYTHON3_SITE_DIR)" -C python3 install
 
 rubymod-install: rubymod
 	$(MAKE) -C ruby install
--- a/libs/esl/python3/Makefile
+++ b/libs/esl/python3/Makefile
@@ -1,6 +1,4 @@
-LOCAL_CFLAGS=`$(PYTHON3) ./python-config --includes`
-LOCAL_LDFLAGS=`$(PYTHON3) ./python-config --ldflags`
-SITE_DIR=$(DESTDIR)/`$(PYTHON3) -c "from distutils.sysconfig import get_python_lib; print (get_python_lib(1))"`
+SITE_DIR=$(DESTDIR)/$(PYTHON3_SITE_DIR)
 
 all: _ESL.so
 
@@ -8,10 +6,10 @@ esl_wrap.cpp:
 	swig3.0 -module ESL -classic -python -c++ -DMULTIPLICITY -threads -I../src/include -o esl_wrap.cpp ../ESL.i
 
 esl_wrap.o: esl_wrap.cpp
-	$(CXX) $(CXX_CFLAGS) $(CXXFLAGS) $(LOCAL_CFLAGS) -c esl_wrap.cpp -o esl_wrap.o
+	$(CXX) $(CXX_CFLAGS) $(CXXFLAGS) $(PYTHON3_CFLAGS) -c esl_wrap.cpp -o esl_wrap.o
 
 _ESL.so: esl_wrap.o
-	$(CXX) $(SOLINK) esl_wrap.o $(MYLIB) $(LOCAL_LDFLAGS) -o _ESL.so -L. $(LIBS)
+	$(CXX) $(SOLINK) esl_wrap.o $(MYLIB) $(PYTHON3_LDFLAGS) -o _ESL.so -L. $(LIBS)
 
 install: _ESL.so
 	mkdir -p $(SITE_DIR)
